Dialog box issue

Ok, I've been trying some work with dialog boxes and am getting very frustrated. Below is an example of one of the problems I've been running into. Running this results in this error

-R-E- DXL: <Line:10> unassigned variable (dbeList)

I found a workaround that stores the value of the list when it is set, but I was hoping for some insight into what I'm doing wrong and how I can fix it.

string    dummyList[]   = {"A","B","C"}
DB      exBox           = null
DBE     dbeLabel        = null
DBE     dbeList         = null
DBE     dbeRun          = null
Module  m               = current Module
string  RFCnum          = null
 
void Run(DB exBox) {
        RFCnum = get(dbeList)
        infoBox("You selected " RFCnum "")
        hide(exBox)
}
 
exBox           = create "Example Problem"
dbeLabel        = label(exBox,"Select from list")
dbeList         = list(exBox, "List:", 20,10,dummyList)
dbeRun          = apply(exBox,"Run",Run)
 
realize(exBox)

iannacones1 - Mon Aug 02 09:05:34 EDT 2010

Re: Dialog box issue
iannacones1 - Mon Aug 02 10:00:13 EDT 2010

I understand this is a scope issue, but there must be some way to easily pull information out of a list when I hit "apply". I've also tried to change the value of a textbox when I set the value of a list, with no success.

Re: Dialog box issue
ambes - Mon Aug 02 10:08:18 EDT 2010

Use

show(exBox)

instead of realize, and your script will work ...

Re: Dialog box issue
SystemAdmin - Mon Aug 02 10:24:37 EDT 2010

ambes - Mon Aug 02 10:08:18 EDT 2010

Use

show(exBox)

instead of realize, and your script will work ...

The realize method should only be used if you need to programatically modify the dialog box between creation and use. You should always call the show method to ensure the dialog box is fully initialised for use.

The documentation talks about show making the dialog box active, without defining what active means. In this case, treat active as a synonym for fully initialised.

Re: Dialog box issue
iannacones1 - Mon Aug 02 10:42:44 EDT 2010

interesting, that defiantly helps but… what do I do if I do need to use realize

string    dummyList[]   = {""}
DB      exBox           = null
DBE     dbeLabel        = null
DBE     dbeList         = null
DBE     dbeRun          = null
Module  m               = current Module
string  attSelect       = null
string  attName         = null
int     iList
 
int fillList(DBE dbeList) {
        iList = 0
        for attName in current Module do {
                insert(dbeList,iList,attName)
                iList++
        }
        return iList
}
 
void Run(DB exBox) {
        attSelect = get(dbeList)
        infoBox("You selected " attSelect "")
        release(exBox)
}
 
exBox           = create "Example Problem"
dbeLabel        = label(exBox,"Select from list")
dbeList         = list(exBox, "List:", 200,10,dummyList)
dbeRun          = apply(exBox,"Run",Run)
 
realize(exBox)
 
if (fillList(dbeList) == 0) {
        insert(dbeList, 0 , "(No Attributes)")
}

Re: Dialog box issue
iannacones1 - Mon Aug 02 10:51:35 EDT 2010

Ok, I got it... thanks you guys!

string    dummyList[]   = {""}
DB      exBox           = null
DBE     dbeLabel        = null
DBE     dbeList         = null
DBE     dbeRun          = null
Module  m               = current Module
string  attSelect       = null
string  attName         = null
int     iList
 
int fillList(DBE dbeList) {
        iList = 0
        for attName in current Module do {
                insert(dbeList,iList,attName)
                iList++
        }
        return iList
}
 
void Run(DB exBox) {
        attSelect = get(dbeList)
        infoBox("You selected " attSelect "")
        hide(exBox)
}
 
exBox           = create "Example Problem"
dbeLabel        = label(exBox,"Select from list")
dbeList         = list(exBox, "List:", 200,10,dummyList)
dbeRun          = apply(exBox,"Run",Run)
 
realize(exBox)
 
if (fillList(dbeList) == 0) {
        insert(dbeList, 0 , "(No Attributes)")
}
 
show(exBox)